package model.Machine;

import java.sql.SQLException;
import java.util.HashMap;

import model.vo.WorkorderVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class MachineDao {
	private SqlMapClient sqlMapClient;
	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}
	//지시사항 vo로 가져오기
	public WorkorderVO workorderCheck() throws SQLException {
		WorkorderVO result = (WorkorderVO) sqlMapClient.queryForObject("machine.workorderCheck");
		//System.out.println(result+"if문 들어가기전~");
		if(result==null){
			WorkorderVO result2=new WorkorderVO();
			result2.setWorkorder_quantity(0);
			result2.setWorkorder_badquantity(0);
			//System.out.println(result2+"if문 안속");
			return result2;
		}else
			return result;
	}
	//에러를 history에 insert
	public void errorInsertHis(HashMap dmap) throws SQLException {
		sqlMapClient.insert("machine.errorInsertHis", dmap);
	}
	//에러를 wip에 insert
	public void errorInsertWip(HashMap dmap) throws SQLException {
		sqlMapClient.insert("machine.errorInsertWip", dmap);
	}
	//마지막 수행이 start인지 알아보는
	public String history_statusCheck(WorkorderVO wvo) throws SQLException {
		return (String) sqlMapClient.queryForObject("machine.history_statusCheck", wvo);
	}
	//성공을 insert 처리
	public void successInsert(WorkorderVO wvo) throws SQLException {
		sqlMapClient.insert("machine.successInsert", wvo);
	}
	//성공난거를 디비 업데이트 하는거
	public void successUpdate(WorkorderVO wvo) throws SQLException {
		sqlMapClient.update("machine.successUpdate", wvo);
	}
	public void soapbaseUse() throws SQLException {
		sqlMapClient.update("machine.soapbaseUse");	
	}
	public void hardenerUse() throws SQLException {
		sqlMapClient.update("machine.hardenerUse");
	}
	public void wrapperUse() throws SQLException {
		sqlMapClient.update("machine.wrapperUse");
	}
	public void oilUse() throws SQLException {
		sqlMapClient.update("machine.oilUse");
	}
}
